<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018-07-27
 * Time: 13:59
 */
$i = $_GET['pn'] ? $_GET['pn'] : 1;
$k = !empty($_GET['kw']) ? $_GET['kw'] : '男科医院';
session_start();
$_SESSION['key'] = $k;

$curl = curl_init();
// 设置你需要抓取的URL
curl_setopt($curl, CURLOPT_URL, "https://www.so.com/s?q={$_SESSION['key']}&pn={$i}");
// 设置header
//curl_setopt($curl, CURLOPT_HEADER, 1);
// 设置cURL 参数，要求结果保存到字符串中还是输出到屏幕上。
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); //不验证证书
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); //不验证证书
// 运行cURL，请求网页
$info = curl_exec($curl);

curl_close($curl);
echo $info;

